linux 查看驱动模块(lsmod)和 驱动设备(ls /dev)

您所在的位置:网站首页 linux 查找驱动 linux 查看驱动模块(lsmod)和 驱动设备(ls /dev)

linux 查看驱动模块(lsmod)和 驱动设备(ls /dev)

2024-07-15 07:46:42| 来源: 网络整理| 查看: 265

一、lsmod

lsmod 命令,用于列出当前 linux 系统中加载的模块。当驱动开发人员编写好驱动代码,并生成驱动代码对应的驱动模块后,可以通过 insmod xxx.ko 将驱动模块(.ko)加载到 linux 操作系统中。最后,通过 lsmod 命令就可以看到 xxx.ko 已经加载到 linux 系统当中了。

驱动代码: back@ubuntu2205:~$ cat driver.c #include #include #include int hello_probe(struct platform_device *pdev) { printk("[%s] match ok\n", __FILE__); return 0; } int hello_remove(struct platform_device *pdev) { printk("[%s] hello_remove\n", __FILE__); return 0 ; } struct platform_driver hello_driver = { .probe = hello_probe, .remove = hello_remove, .driver.name = "yikoulinux", }; static int hello_init(void) { printk("[%s] hello_init\n", __FILE__); return platform_driver_register(&hello_driver); } static void hello_exit(void) { printk("[%s] hello_exit\n", __FILE__); platform_driver_unregister(&hello_driver); return; } MODULE_LICENSE("GPL"); module_init(hello_init); module_exit(hello_exit); back@ubuntu2205:~$ cat device.c #include #include #include void hello_release(struct device *dev) { printk("[%s] hello_release\n",__FILE__); return; } struct platform_device hello_device ={ .name = "yikoulinux", .id = -1, .dev.release = hello_release, //hardware TBD }; static int hello_init(void) { printk("[%s] hello_init\n", __FILE__); return platform_device_register(&hello_device); } static void hello_exit(void) { printk("[%s] hello_exit\n", __FILE__); platform_device_unregister(&hello_device); return; } MODULE_LICENSE("GPL"); module_init(hello_init); module_exit(hello_exit); back@ubuntu2205:~$ ls -lh total 1.1M -rw-r--r-- 1 back back 709 8月 3 12:13 device.c -rw-rw-r-- 1 back back 5.6K 8月 3 12:18 device.ko -rw-r--r-- 1 back back 829 8月 3 12:13 driver.c -rw-rw-r-- 1 back back 5.3K 8月 3 12:18 driver.ko back@ubuntu2205:~$

在这里插入图片描述 可以看到,我们通过 insmod 命令将 1.1 中的 device.ko 和 driver.ko加载到系统后,lsmod 就会发现我们 insmod 加载的 .ko 模块。

二、其他常见信息的查看

查看CPU信息: cat /proc/cpuinfo 查看板卡信息:cat /proc/pci 查看PCI信息: lspci 例子: lspci |grep Ethernet 查看网卡型号 查看内存信息:cat /proc/meminfo 查看USB设备: cat /proc/bus/usb/devices 查看键盘和鼠标:cat /proc/bus/input/devices 查看系统硬盘信息和使用情况:fdisk & disk - l & df 查看各设备的中断请求(IRQ): cat /proc/interrupts 查看系统体系结构:uname -a

dmidecode查看硬件信息,包括bios、cpu、内存等信息 dmesg | more 查看硬件信息

三、ls /dev

ls /dev 命令用于查看系统中的驱动设备,包括字符设备、块设备。一个驱动模块可以注册多个设备文件。

如字符设备 i2c-0 ~ i2c-4,这5个都是字符设备,它们的主设备号都是 89,此设备号为 0 ~ 4。 同理,块设备 loop0 ~ loop7,它们的主设备号都是 7,此设备号为 0 ~ 7。



【本文地址】

公司简介

联系我们

今日新闻


点击排行

实验室常用的仪器、试剂和
说到实验室常用到的东西,主要就分为仪器、试剂和耗
不用再找了,全球10大实验
01、赛默飞世尔科技(热电)Thermo Fisher Scientif
三代水柜的量产巅峰T-72坦
作者:寞寒最近,西边闹腾挺大,本来小寞以为忙完这
通风柜跟实验室通风系统有
说到通风柜跟实验室通风,不少人都纠结二者到底是不
集消毒杀菌、烘干收纳为一
厨房是家里细菌较多的地方,潮湿的环境、没有完全密
实验室设备之全钢实验台如
全钢实验台是实验室家具中较为重要的家具之一,很多

推荐新闻


图片新闻

实验室药品柜的特性有哪些
实验室药品柜是实验室家具的重要组成部分之一,主要
小学科学实验中有哪些教学
计算机 计算器 一般 打孔器 打气筒 仪器车 显微镜
实验室各种仪器原理动图讲
1.紫外分光光谱UV分析原理:吸收紫外光能量,引起分
高中化学常见仪器及实验装
1、可加热仪器:2、计量仪器:(1)仪器A的名称:量
微生物操作主要设备和器具
今天盘点一下微生物操作主要设备和器具,别嫌我啰嗦
浅谈通风柜使用基本常识
 众所周知,通风柜功能中最主要的就是排气功能。在

专题文章

    CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭